﻿//=====================================================================================================
// ┌────────────────────────────────────────────────
// │  control class :: requirement
// │  1 :: rms.core.js
// │  2 :: rms.basecontrol.js
// │  3 :: 
// │  4 :: 
// │  5 ::
// └────────────────────────────────────────────────
//=====================================================================================================
// Dialog Constructor Class
//=====================================================================================================
(function (RMS) {
    var Dialog = RMS.BaseControl.prototype.extend(),
        defaults = {
            height: 145,
            width: 270,
            resizable: false,
            isModal: true,
            modalOpacity: 0.1
        };

    Dialog.prototype.init = function (settings) {
        if (settings) {
            defaults = $.extend(true, defaults, settings);
        }
    };

    Dialog.prototype.binding = function () {
        console.log('::binding');
    };

    Dialog.prototype.getSettings = function () {
        console.log('::getSettings');
        return defaults;
    };

    Dialog.prototype.updateSettings = function (settings) {
        if (settings) {
            defaults = $.extend(true, defaults, settings);
            this.load();
        }
    };

    Dialog.prototype.load = function () {
        console.log('::load');
    };

    RMS.CDialog = Dialog;
})(RMS);

//=====================================================================================================
// Dialog Constructor Class
//=====================================================================================================
(function (RMS) {
    var Alert = RMS.BaseControl.prototype.extend(),
        defaults = {
            resizable: false,
            draggable: true,
            isModal: true,
            modalOpacity: 0.1,
            zIndex: 99,

            okButton: '&nbsp;Yes&nbsp;',
            cancelButton: '&nbsp;No&nbsp;',
            showCloseButton: false,
            showCollapseButton: false,

            type: 0,
            message: '',
            title: 0,

            id: new Date().getTime().toString()
        };

    Alert.prototype.init = function (settings) {
        if (settings) {
            defaults = $.extend(true, defaults, settings);
        }
    };

    Alert.prototype.binding = function () {
        console.log('::binding');
    };

    Alert.prototype.getSettings = function () {
        console.log('::getSettings');
        return defaults;
    };

    Alert.prototype.updateSettings = function (settings) {
        if (settings) {
            defaults = $.extend(true, defaults, settings);
            this.load();
        }
    };

    Alert.prototype.load = function () {
        console.log('::load');
    };

    RMS.CAlert = Alert;
})(RMS);

//// ┌────────────────────────────────────────────────
//// │  control class :: requirement                          
//// │  1 :: rms.control.js
//// │  2 :: 
//// │  3 :: 
//// │  4 :: 
//// │  5 ::
//// └────────────────────────────────────────────────
////=====================================================================================================
////
////=====================================================================================================
//if (typeof RMS == 'undefined') RMS = {};
///*
//CDialog Constructor Class
//@param:  {object} properties create control
//@return: {object} control class
//*/
//RMS.CDialog = function (settings, callback) {
//    this.instance = null;
//    this.settings = {
//        height: 145,
//        width: 270,
//        resizable: false,
//        isModal: true,
//        modalOpacity: 0.1
//    };
//    $.extend(true, this.settings, settings);
//
//    this.init = function () {
//        this.instance = new RMS.CControl(this.settings, function () {
//            //somthing to do after control render
//        });
//        this.instance.init();
//    };
//
//    this.update = function (settings, value) {
//        if (value === void 0) { //settings is object
//            $.extend(true, this.settings, settings);
//        }
//        else { //if value is defined then settings is the key
//            this.settings[settings] = value;
//        }
//        return this.instance;
//    };
//
//    this.getInstance = function () {
//        return this.instance;
//    };
//};
//
///*
//Alert Constructor Class
//@param:  {object} properties create control
//@return: {object} control class
//*/
//RMS.CAlert = function (settings, callback) {
//    this.instance = null;
//    this.settings = {
//        resizable: false,
//        draggable: true,
//        isModal: true,
//        modalOpacity: 0.1,
//        zIndex: 99,
//
//        okButton: '&nbsp;Yes&nbsp;',
//        cancelButton: '&nbsp;No&nbsp;',
//        showCloseButton: false,
//        showCollapseButton: false,
//
//        type: 0,
//        message: '',
//        title: 0,
//
//        id: new Date().getTime().toString()
//    };
//    $.extend(true, this.settings, settings);
//
//    console.log('::alert', this.settings);
//    this.ctrID = this.settings.id;
//
//    this.init = function () {
//        console.log('::alert::init', this.settings);
//        if (this.ctrID.indexOf('#') == -1 && this.ctrID.indexOf('.') == -1) {
//            this.ctrID = '#' + this.ctrID;
//        }
//
//        var message = this.settings.message,
//            title = this.settings.title;
//        switch (this.settings.type.toString()) {
//            case "1":
//            case "2":       //help  
//
//                break;
//            case "3":       //exclamation
//
//                break;
//            case "4":       //asterisk
//
//                break;
//            case "5":       //stop
//
//                break;
//            case "6":       //error
//                title = 1;
//
//                break;
//            case "7":       //warning
//
//                break;
//            case "8":       //info
//
//                break;
//            case "9":       //success
//                title = 1;
//
//                break;
//            case "10":
//            case "confirm": //confirm                
//                title = 2;
//                break;
//            case "11":      //announcement
//            case "announcement":
//
//                break;
//            case "custom":  //custom
//
//                break;
//            default:        //alert
//
//                break;
//        }
//
//        switch (title) {
//            case 0:
//                title = "INFORMATION";
//                break;
//            case 1:
//                title = "ACTION RESULT";
//                break;
//            case 2:
//                title = "ACTION CONFIRM";
//                break;
//        }
//
//        this.settings.message = message;
//        this.settings.title = title;
//        console.log(this.settings);
//        //add html to body
//        this.initContent();
//        //apply to dialog
//        this.instance = new RMS.CDialog(this.settings, callback);
//        this.instance.init();
//    };
//    this.initContent = function (settings) {
//        var tmp = '<div id="{5}">' +
//                        '<div><img class="icon icon-head" src="{0}" alt="" />{1}</div>' +
//                        '<div>' +
//                            '<div>' +
//                                '<img class="icon icon-content" src="{2}" alt="" />{3}' +
//                            '</div>' +
//                            '<div>' +
//                                '<div class="dialog-buttons">' +
//                                    '<input type="button" id="btnOk" value="OK" />' +
//                                    '<input type="button" id="btnCancel" value="Cancel" />' +
//                                '</div>' +
//                            '</div>' +
//                        '</div>' +
//                    '</div>';
//        var html = $.string.Format(tmp, settings.iconTitle || '', settings.title, settings.iconMessage || '', settings.message, settings.id);
//        $('body').append(html);
//    };
//
//    this.show = function () {
//        if (this.instance) {
//            this.instance.show();
//        }
//    };
//
//    this.hide = function () {
//        if (this.instance) {
//            this.instance.hide();
//        }
//    };
//
//    this.update = function (settings, value) {
//        if (value === void 0) { //settings is object
//            $.extend(true, this.settings, settings);
//        }
//        else { //if value is defined then settings is the key
//            this.settings[settings] = value;
//        }
//        return this.instance;
//    };
//
//    return this;
//};